<template>
  <a-card :bordered='false'>

    <!-- 查询区域 -->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">-->
          <!--<a-form-item-->
          <!--label="入库年月">-->
          <!--<a-month-picker placeholder="请选择年月" format="YYYY-MM" valueFormat="YYYY-MM" v-model="queryParam.ym"-->
          <!--v-decorator="['ym', {}]"/>-->
          <!--</a-form-item>-->
          <!--</a-col>-->
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item
              label='开始年月'>
              <a-month-picker style='width:100%' placeholder='请选择开始年月' format='YYYY-MM' valueFormat='YYYY-MM'
                              v-model='queryParam.ymStart' v-decorator="['ymStart', {}]" />
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item
              label='结束年月'>
              <a-month-picker style='width:100%' placeholder='请选择结束年月' format='YYYY-MM' valueFormat='YYYY-MM'
                              v-model='queryParam.ymEnt' v-decorator="['ymEnt', {}]" />
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='省份'>
              <a-input placeholder='请输入省份' v-model='queryParam.province'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='地址'>
              <a-input placeholder='请输入地址模糊查询' v-model='queryParam.address'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='经销商编码'>
              <a-input placeholder='请输入经销商编码' v-model='queryParam.custCode'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='经销商名称'>
              <a-input placeholder='请输入经销商名模糊查询' v-model='queryParam.custName'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='品类'>
              <a-input placeholder='请输入品类' v-model='queryParam.productType'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='产品编码'>
              <a-input placeholder='请输入产品编码' v-model='queryParam.productCode'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='产品名称'>
              <a-input placeholder='请输入产品名称模糊查询' v-model='queryParam.productName'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='批次号'>
              <a-input placeholder='请输入批次号' v-model='queryParam.flot'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='国内批次号'>
              <a-input placeholder='请输入国内批次号' v-model='queryParam.auxPropId'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <a-form-item label='大区'>
              <a-input placeholder='请输入大区' v-model='queryParam.dq'></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <a @click='handleToggleSearch' style='margin-left: 8px'>
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!--    &lt;!&ndash; 操作按钮区域 &ndash;&gt;-->
    <!--    <div class="table-operator">-->
    <div class='table-operator'>
      <!--      <a-button type="primary" icon="update" @click="doSellInData">数据更新</a-button>-->
      <a-button type='primary' icon='download' @click="downExportXls('sellin_report')">导出</a-button>
    </div>

    <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
    <!--        <a-menu slot="overlay">-->
    <!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
    <!--        </a-menu>-->
    <!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
    <!--      </a-dropdown>-->
    <!--    </div>-->

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择 <a style='font-weight: 600'>{{
          selectedRowKeys.length }}</a>项
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        @change='handleTableChange'>

        <span slot='action' slot-scope='text, record'>
          <a @click='handleEdit(record)'>编辑</a>

          <a-divider type='vertical' />
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
              <a-menu-item>
                <a-popconfirm title='确定删除吗?' @confirm='() => handleDelete(record.id)'>
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!--    &lt;!&ndash; 表单区域 &ndash;&gt;-->
    <!--    <sfaVisitSummaryEntity-modal ref="modalForm" @ok="modalFormOk"></sfaVisitSummaryEntity-modal>-->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction, postAction } from '@/api/manage'
// import SfaVisitSummaryEntityModal from './modules/SfaVisitSummaryModal'
import { PageListMixin } from '@/mixins/PageListMixin'


export default {
  name: 'SfaVisitSummaryList',
  mixins: [PageListMixin],

  data() {
    return {
      description: 'sellIn页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '年月',
          align: 'center',
          dataIndex: 'ym'
        },
        {
          title: '大区',
          align: 'center',
          dataIndex: 'dq'
        },
        {
          title: '省份',
          align: 'center',
          dataIndex: 'province'
        },
        {
          title: '城市',
          align: 'center',
          dataIndex: 'city'
        },
        {
          title: '区县',
          align: 'center',
          dataIndex: 'area'
        },
        {
          title: '详细地址',
          align: 'center',
          dataIndex: 'address'
        },
        {
          title: '大区经理',
          align: 'center',
          dataIndex: 'dqManger'
        },
        {
          title: '省经理',
          align: 'center',
          dataIndex: 'provinceManager'
        },
        {
          title: '销售主管',
          align: 'center',
          dataIndex: 'saleManager'
        },
        {
          title: '经销商编码',
          align: 'center',
          dataIndex: 'custCode'
        },

        {
          title: '经销商名称',
          align: 'center',
          dataIndex: 'custName'
        },
        {
          title: '品牌',
          align: 'center',
          dataIndex: 'brandName'
        },
        {
          title: '品类',
          align: 'center',
          dataIndex: 'productType'
        },
        {
          title: '产品编码',
          align: 'center',
          dataIndex: 'productCode'
        },
        {
          title: '产品名称',
          align: 'center',
          dataIndex: 'productName'
        },
        {
          title: '箱规',
          align: 'center',
          dataIndex: 'boxNum'
        },
        {
          title: '条形码',
          align: 'center',
          dataIndex: 'barCode'
        },
        {
          title: '批次号',
          align: 'center',
          dataIndex: 'flot'
        },
        {
          title: '国内批次号',
          align: 'center',
          dataIndex: 'auxPropId'
        },
        {
          title: '有机码',
          align: 'center',
          dataIndex: 'syCode'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'num'
        },
        {
          title: '订单总金额',
          align: 'center',
          dataIndex: 'amount'
        },
        {
          title: '销售审批时间',
          align: 'center',
          dataIndex: 'saleAuditDate'
        },
        {
          title: '销售运营审批时间',
          align: 'center',
          dataIndex: 'yyAuditDate'
        },
        {
          title: '供应链审批时间',
          align: 'center',
          dataIndex: 'gyAuditDate'
        },
        {
          title: 'sop审核时间',
          align: 'center',
          dataIndex: 'fsopDate'
        },
        {
          title: '财务审批时间',
          align: 'center',
          dataIndex: 'ffinanceDate'
        },
        {
          title: '出库日期',
          align: 'center',
          dataIndex: 'outDate'
        },
        {
          title: '经销商入库时间',
          align: 'center',
          dataIndex: 'custInDate'
        },
        {
          title: '经销商入库数量',
          align: 'center',
          dataIndex: 'custinNum'
        },
        {
          title: '回单日期',
          align: 'center',
          dataIndex: 'raeceiptDate'
        }
      ],
      url: {
        list: window._CONFIG['domianSfaURL'] + '/sy/sellInController/findPageList',
        exportXlsUrl: window._CONFIG['domianSfaURL'] + '/sellInVoService/todoExcel',
        doSellInData: window._CONFIG['domianSfaURL'] + '/sy/sellInController/doSellInData'

        // delete: "/visit/sfaVisitSummaryEntity/delete",
        // deleteBatch: "/visit/sfaVisitSummaryEntity/deleteBatch",
        // importExcelUrl: "visit/sfaVisitSummaryEntity/importExcel",
      }
    }
  },

  methods: {
    doSellInData() {
      var that = this
      if (!this.url || !this.url.doSellInData) {
        // this.$message.error("请设置url.list属性!")
        return
      }
      // var params = this.getQueryParams();//查询条件
      this.loading = true
      postAction(this.url.doSellInData).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
        that.loading = false
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>